package com.bbzn.user.client.dao.opthis;

import com.bbzn.user.client.dataobject.OptHis;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Date;

@Repository
public interface OptHisRepository extends MongoRepository<OptHis,Long> {

    @Query(value = "{'createTime': {$gte : ?0, $lte :?1},'imei':{$regex:?2},'createBy':{$regex:?3},'userId':?4}")
    Page<OptHis> findAllByCreateTimeBetweenOrderByCreateTime(
            Date startTime, Date endTime,String imei,String createBy,Long userId, Pageable pageable);

    @Query(value = "{'createTime': {$gte : ?0, $lte :?1},'imei':{$regex:?2},'userId':?3}")
    Page<OptHis> findAllByImeiBetweenOrderByCreateTime(
            Date startTime, Date endTime,String imei,Long userId,Pageable pageable);

    @Query(value = "{'createTime': {$gte : ?0, $lte :?1},'userId':?2}")
    Page<OptHis> findAllByCreateTimeBetweenOrderByCreateTime(
            Date startTime, Date endTime,Long userId,Pageable pageable);

    @Query(value = "{'createTime': {$gte : ?0, $lte :?1},'createBy':{$regex:?2},'userId':?3}")
    Page<OptHis> findAllByCreateByBetweenOrderByCreateTime(
            Date startTime, Date endTime,String createBy,Long userId,Pageable pageable);
}